<?php
class Model_Album extends Zend_Db_Table_Abstract{
    public $_name = "albums";
    public $_primary = "id";
    public function listAll(){
        return $this->fetchAll()->toArray();
    }
    function getAlbum($id){
        $id = (int)$id;
        $result = $this->fetchRow('id = '.$id);
        if(!$result) {
            throw new Exception("Could not find row $id");
        }
        return $result->toArray();
    }

    public function addAlbum($title,$artist){
        $data = array("title"=>$title,"artist"=>$artist,);
        if($this->insert($data)){
            return true;
        }
        else {
            return false;
        }
    }
    
    
     public function updateAlbum($id, $artist, $title)
    {
        $data = array(
            'title' => $title,
            'artist' => $artist,
        );
        $this->update($data, 'id = '. (int)$id);
    }
    function deleteAlbun($id) {
        $return = $this->delete('id='.(int)$id);
        if($return){
            return true;
        }
        else {
            return false;
        }
    }

    public function addAlbum12($title,$artist){
        $data = array('title'=>$title,'artist'=>$artist);
        $this->insert($data);
    }
     public function addAlbum1($title,$artist)
    {
        $data = array(
            'title' => $title,
            'artist' => $artist,
        );
        $this->insert($data);
    }

}
?>
